<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:56:"F:\cash\public/../application/admin\view\menu\index.html";i:1538618524;s:49:"F:\cash\application\admin\view\public\header.html";i:1538810552;}*/ ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>必普测试系统</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/xadmin/css/font.css">
    <link rel="stylesheet" href="/static/xadmin/css/xadmin.css">
    <script type="text/javascript" src="/static/xadmin/js/jquery.min.js"></script>
    <script src="/static/xadmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/xadmin/js/xadmin.js"></script>
    <!--ztree-->
    <link rel="stylesheet" href="/static/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="/static/ztree/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="/static/ztree/js/jquery.ztree.excheck.js"></script>
    <script>
        var choose_province = "<?php echo url('area/ajax_province'); ?>",
            choose_city = "<?php echo url('area/ajax_city'); ?>",
            choose_area = "<?php echo url('area/ajax_area'); ?>";
    </script>
</head>
<body>

  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <?php if(in_array(($menu_add), is_array($identification)?$identification:explode(',',$identification))): ?>
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so layui-form-pane" attr-url="<?php echo url('menu/add',['pid'=>0]); ?>">
          <input class="layui-input" placeholder="顶级权限名称" name="name">
          <input class="layui-input" placeholder="排序" name="sort">
          <button class="layui-btn"  lay-submit lay-filter="formDemo"><i class="layui-icon"></i>增加</button>
        </form>
      </div>
      <?php endif; ?>
      <table class="layui-table layui-form">
        <thead>
          <tr>
            <th width="20">
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th width="70">ID</th>
            <th>栏目名</th>
            <th width="50">排序</th>
            <th width="50">显示</th>
            <th width="220">操作</th>
        </thead>
        <tbody class="x-cate">
          <?php if(is_array($menus) || $menus instanceof \think\Collection || $menus instanceof \think\Paginator): $i = 0; $__LIST__ = $menus;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
          <tr cate-id="<?php echo $vo['id']; ?>" fid="<?php echo $vo['fid']; ?>">
            <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td><?php echo $vo['id']; ?></td>
            <td>
              <?php echo str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$vo['level']); ?>
              <i class="layui-icon x-show" status='true'>&#xe623;</i>
              <?php echo $vo['name']; ?>
            </td>
            <?php if(in_array(($menu_edit_sort), is_array($identification)?$identification:explode(',',$identification))): ?>
            <td id="blur_sort"><input type="text" class="layui-input x-sort" attr-id="<?php echo $vo['id']; ?>" name="show" value="<?php echo $vo['sort']; ?>"></td>
            <?php else: ?>
            <td><?php echo $vo['sort']; ?></td>
            <?php endif; if(in_array(($menu_edit_show), is_array($identification)?$identification:explode(',',$identification))): ?>
            <td id="edit_show">
              <input type="checkbox" name="show" lay-skin="switch" lay-filter="encrypt"  lay-text="开启|停用" attr-id="<?php echo $vo['id']; ?>"  <?php if($vo['show'] == '1'): ?>checked="checked"<?php endif; ?>>
            </td>
            <?php else: ?>
            <td>
              <span class='layui-btn' id='btnok'>显示</span>
            </td>
            <?php endif; ?>
            <td class="td-manage">
              <button class="layui-btn layui-btn layui-btn-xs"  onclick="xm_admin_show('编辑','admin-edit.html')" ><i class="layui-icon">&#xe642;</i>编辑</button>
              <?php if(in_array(($menu_add), is_array($identification)?$identification:explode(',',$identification))): ?>
              <button class="layui-btn layui-btn-warm layui-btn-xs"  onclick="xm_admin_show('添加子栏目','<?php echo url('menu/add',['fid'=>$vo['id']]); ?>')" ><i class="layui-icon">&#xe642;</i>添加子栏目</button>
              <?php endif; ?>
              <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del(this,'要删除的id')" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
            </td>
          </tr>
          <?php endforeach; endif; else: echo "" ;endif; ?>
        </tbody>
      </table>
    </div>
    <script>
      sort_url = "<?php echo url('menu/edit_sort'); ?>";
      show_url = "<?php echo url('menu/edit_show'); ?>";
      layui.use(['form','layer'], function(){
          var table = layui.table,form = layui.form,layer = layui.layer;
          form.on('switch(encrypt)', function(data){
              var id = $(data.elem).attr('attr-id');
              if(data.elem.checked == true){
                  show = 1;
              }else{
                  show  =  0
              }
              $.ajax({
                  url : show_url,
                  type : 'post',
                  data : {id : id,show : show},
                  success : function(result){
                      if(result.code == 200){
                          layer.msg(result.msg,{icon:1},function(){
                              location.href = result.data;
                          });
                      }else if (result.code == 400){
                          layer.msg(result.msg,{icon:2},function(){
                              location.href = result.data;
                          });
                      }
                  }
              });
//              console.log(data.elem); //得到checkbox原始DOM对象
//              console.log(data.elem.checked); //开关是否开启，true或者false
//              console.log(data.value); //开关value值，也可以通过data.elem.value得到
//              console.log(data.othis); //得到美化后的DOM对象
          });
      });

      //修改input值 blur
      $('#blur_sort input').blur(function(){
          var sort = $(this).val();
          var id = $(this).attr('attr-id');
          $.ajax({
              url : sort_url,
              data : {
                  sort : sort,
                  id : id
              },
              type : 'post',
              success : function(result){
                  if(result.code == 400){
                      layui.use('layer', function(){
                          var layer = layui.layer;
                          layer.msg(result.msg,{icon:2},function(){
                              location.href = result.data;
                          });
                      });
                  }else if(result.code == 200){
                      layui.use('layer', function(){
                          var layer = layui.layer;
                          layer.msg(result.msg,{icon:1},function(){
                              location.href = result.data;
                          });
                      });
                  }
              }
          });
      });
    </script>
    <script src="/static/admin/js/common.js"></script>
</body>
</html>